package com.stx.blog.action;

import java.util.Date;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.stx.blog.service.UserService;
import com.stx.blog.util.BlogUtil;
import com.stx.blog.vo.UserVo;

public class ChangePasswordAction extends ActionSupport{
     private UserService us;
     private UserVo     uv;
     private String  passwords;
     private String lastTime;
     private BlogUtil bu;
	public BlogUtil getBu() {
		return bu;
	}
	public void setBu(BlogUtil bu) {
		this.bu = bu;
	}
	public String getLastTime() {
		return lastTime;
	}
	public void setLastTime(String lastTime) {
		this.lastTime = lastTime;
	}
	public String getPasswords() {
		return passwords;
	}
	public void setPasswords(String passwords) {
		this.passwords = passwords;
	}
	public UserService getUs() {
		return us;
	}
	public void setUs(UserService us) {
		this.us = us;
	}
	public UserVo getUv() {
		return uv;
	}
	public void setUv(UserVo uv) {
		this.uv = uv;
	}
    public String changePassword(){
    	uv.setBlogLastmodifytime(new Date());
    	us.changePassword(uv);
    	
    	uv=us.getUsesr(uv.getBuid());
		HttpSession s=ServletActionContext.getRequest().getSession();
		s.removeAttribute("user");
		s.setAttribute("user", uv);	
//			uv=us.getUser(uv);
//			s.removeAttribute("user");
//			s.setAttribute("user", uv);
    	addActionError("密码已修改完成");
    	return "update";
    }
}
